package com.ihr360.payroll.service.staff.validator;

import com.google.common.collect.Lists;
import com.ihr360.payroll.request.StaffPayrollInfoRequest;
import com.ihr360.payroll.request.StaffPayrollInfosRequest;
import com.ihr360.validation.ValidationUtils;
import com.ihr360.validation.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AbnormalityStaffSalaryProfileValidator implements Validator<StaffPayrollInfoRequest> {

    @Autowired
    StaffPayrollInfosValidator staffPayrollInfosValidator;

    @Override
    public boolean supports(Class<?> clazz) {
        return StaffPayrollInfoRequest.class.equals(clazz);
    }

    @Override
    public void validate(StaffPayrollInfoRequest target) {
        ValidationUtils.rejectIfEmpty(target,null,"数据异常，请求参数不能为空！");
        StaffPayrollInfosRequest payRollInfos = new StaffPayrollInfosRequest();
        payRollInfos.setPayrollInfos(Lists.newArrayList(target));
        staffPayrollInfosValidator.validate(payRollInfos);
    }
}
